/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * 
 * JNewButton.java
 *
 * Created on 12/04/2013
 *
 **
 * @author Abdel
 */

package JNew.gui;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import javax.swing.JButton;


public class JNewButton extends JButton{
    private Color bordeColor;
    private Color colorClaro;
    private Color colorOscuro;

    public JNewButton(String nombre) {
        super(nombre);
        this.setForeground( Color.WHITE );
        this.setContentAreaFilled(false);
        this.bordeColor = new Color(0,0,0);
        this.colorClaro = new Color(120,120,120);
        this.colorOscuro = new Color(0,0,0);
        //se cambia de cursor default por otro, el de la "manita"
        this.setCursor(new Cursor(Cursor.HAND_CURSOR));  
    }

    public JNewButton(String nombre, Color colorClaro, Color colorOscuro) {
        super(nombre);
        this.setForeground( Color.WHITE );
        this.setContentAreaFilled(false);
        this.bordeColor = new Color(0,0,0);
        this.colorClaro = colorClaro;
        this.colorOscuro = colorOscuro;
        //se cambia de cursor default por otro, el de la "manito"
        this.setCursor(new Cursor(Cursor.HAND_CURSOR));  
    }


    public void setBordeColor(Color color){
        bordeColor = color;
    }

    @Override
    protected void paintBorder(Graphics g) {
        int ancho = this.getWidth();
        int alto = this.getHeight();

        g.setColor( bordeColor );
        g.drawRect(0,0, ancho-1, alto-1);

    }

    @Override
    protected void paintComponent(Graphics g) {
        int ancho = this.getWidth();
        int alto = this.getHeight();

        if( this.getModel().isArmed() ){ //Bonton Presionado
            g.setColor( colorClaro );
            g.fillRect(0,0, ancho , alto);
        }else{

            g.setColor( colorClaro );
            g.fillRect(0, 0, ancho, alto);

            g.setColor( colorOscuro );
            g.fillRect(0, alto/2, ancho, alto);
        }

        super.paintComponent(g);
    }
}
